package net.timico.messaging;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;

import org.apache.activemq.ActiveMQConnectionFactory;

/**
 * This type describes the activeMQ Broker.
 * <p>
 * 
 * @author $Author: sleroy $
 * @since 1 oct. 2011
 * @copyright Copyright (C) 2010-2012 TOCEA
 */

public class ActiveMQApp {

	public final static String queueName = "passerCommande";
	Session session;
	Connection connection;

	public void runConnection() {
		// Create a ConnectionFactory
		final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
				"tcp://localhost:61616");
		try {
			connection = connectionFactory.createConnection();
			connection.start();
			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
			session.createQueue(queueName);

		} catch (JMSException e) {
			e.printStackTrace();
		}
	}

	public static void main(final String[] args) throws JMSException {

		ActiveMQApp activeMQ = new ActiveMQApp();
		activeMQ.runConnection();

	}

}
